package com.education.myvideoview;

import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;

import java.io.File;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {

    @InjectView(R.id.button_play)
    Button buttonPlay;
    @InjectView(R.id.video_view)
    VideoView videoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
    }

    @OnClick(R.id.button_play)
    public void onClick() {
        videoView.setVideoPath(Environment.getExternalStorageDirectory()
                + File.separator + "duck.mp4");
//        videoView.setVideoURI(Uri.parse("http://flv2.bn.netease.com/tvmrepo/2016/7/L/S/EBQ3V1KLS/SD/EBQ3V1KLS-mobile.mp4"));
        videoView.setMediaController(new MediaController(MainActivity.this));
        videoView.start();
    }
}
